//
//  SelectTheCircleViewController.swift
//  OnceNectar
//
//  Created by 法正磊 on 2018/3/2.
//  Copyright © 2018年 com.inwhoop. All rights reserved.
//

import UIKit

class SelectTheCircleViewController: BaseViewController, AddCornerUIRectCorner, BottomShadow, UITableViewDelegate, UITableViewDataSource {
    let cellHeight: CGFloat = 60
     let footerHeight: CGFloat = 60
    @IBOutlet weak var mainTableView: UITableView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setUI()
        // Do any additional setup after loading the view.
    }
    
    func setUI() {
     self.titleLabel(text: "选择圈子", "icon_address")
        mainTableView.register(UINib(nibName: "\(SelectTheCircleTableViewCell.self)", bundle: nil), forCellReuseIdentifier: "cell")
        mainTableView.tableFooterView = setFooterView()
    }
    
    override func setNavigation() {
//        navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "icon_determine"), style: .done, target: self, action: #selector(doneTap))
    }
    
//    @objc func doneTap() {
//
//    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 10
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as? SelectTheCircleTableViewCell
        if indexPath.row == 0 {
            addCornerWithView(aView: cell!, aCorners: [.topLeft, .topRight], aSize: CGSize(width: CORNERRADIUS, height: CORNERRADIUS))
        } else {
            cell?.layer.mask?.removeFromSuperlayer()
        }
        
        return cell!
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return cellHeight
    }
    
    func setFooterView() -> UIView {
        let mainView = UIView()
        mainView.frame = CGRect(x: 0, y: 0, width: ScreenWidth, height: footerHeight)
        mainView.backgroundColor = ONColor.cellBGColor
        setShadow(view: mainView, opacity: bottomShadowOpacity, size: bottomShadowOffset, color: UIColor.black, cornerradius: CORNERRADIUS)
        let footerView = UIView()
        footerView.frame = CGRect(x: 0, y: 0, width: ScreenWidth - 20, height: footerHeight)
        footerView.backgroundColor = UIColor(hex: 0xEEEEEE)
        mainView.addSubview(footerView)
        let button = UIButton(frame: CGRect(x: 0, y: 20, width: ScreenWidth - 20, height: 40))
        button.backgroundColor = ONColor.searchButtomColor
        button.setImage(UIImage(named: "bottom_button_ico"), for: .normal)
        footerView.addSubview(button)
        
        self.addCornerWithView(aView: footerView, aCorners: [.bottomLeft,.bottomRight], aSize: CGSize(width: CORNERRADIUS, height: CORNERRADIUS))
        
        return mainView
    }

}
